package com.yoo.ons.function.launcher

import android.util.Log
import com.yoo.chat.kit.utils.RongConfigUtil
import com.yoo.module_base.utils.SaveDeviceUtil
import com.yoo.ons.base.BaseVMActivity
import com.yoo.ons.databinding.ActivityLauncherBinding
import com.yoo.ons.function.MainActivity
import com.yoo.ons.function.login.LoginActivity
import com.yoo.ons.function.register.RegisterActivity
import com.yoo.ons.util.Injections.mainHandler

/**
 * 启动页
 */
class LauncherActivity : BaseVMActivity<ActivityLauncherBinding, LauncherViewModel>(
    ActivityLauncherBinding::inflate,
    LauncherViewModel::class.java
) {
    override fun initData() {
        mainHandler.postDelayed({
            if (SaveDeviceUtil.getToken()==null || !SaveDeviceUtil.getUserValid()){
                //跳转登录
                LoginActivity.start(this,SaveDeviceUtil.getDeleteAccount())
            }else{
                MainActivity.start(this)
            }
            finish()
        }, 3000)
        setRongConfig()
    }

    override fun onDestroy() {
        super.onDestroy()
        binding.lottieLauncherAnim.cancelAnimation()
    }

    fun setRongConfig() {
        RongConfigUtil.configurationRong()
    }

}